/**
 * @Author: XXHH
 * @CreateTime: 2025-01-08
 */
class SingletonLazyThread{
    private static volatile SingletonLazyThread instance = null;
    private static Object locker = new Object();
    private SingletonLazyThread(){

    }
    public static SingletonLazyThread getInstance(){
        if (instance == null){
            synchronized (locker) {
                if (instance == null) {
                    instance = new SingletonLazyThread();
                }
            }
        }
        return instance;
    }

//    public synchronized static SingletonLazyThread getInstance(){
//        if (instance == null){
//            instance = new SingletonLazyThread();
//        }
//        return instance;
//    }


}
public class Demo36 {
    public static void main(String[] args) {
        SingletonLazyThread s = SingletonLazyThread.getInstance();
        SingletonLazyThread s2 = SingletonLazyThread.getInstance();
        System.out.println(s == s2);
    }
}
